﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace MediaPortal.Plugins.Trailers
{

  public enum VideoQuality
  {
    UNKNOWN,
    SMALL,
    MEDIUM,
    LARGE,
    SD,
    HD,
    HD480,
    HD720,
    FULLHD
  }

  public class Video
  {
    private string _label;
    private DateTime _date = DateTime.MinValue;
    private TimeSpan _length = TimeSpan.Zero;
    private string _thumb = string.Empty;

    public Dictionary<VideoQuality, Uri> Size = new Dictionary<VideoQuality, Uri>();

    public string Label
    {
      get { return _label; }
      set { _label = value; }
    }

    public DateTime Date
    {
      get { return _date; }
      set { _date = value; }
    }

    public TimeSpan Duration
    {
      get { return _length; }
      set { _length = value; }
    }

    public string Thumb
    {
      get { return _thumb; }
      set { _thumb = value; }
    }

    public Video(string Label)
    {
      _label = Label;
    }

    public string Description { get; set; }

  }

  public class VideoCollection : CollectionBase
  {

    public int Add(Video item)
    { 
      return List.Add(item);
    }
    public void Insert(int index, Video item)
    {
      List.Insert(index, item);
    }
    public void Remove(Video item)
    {
      List.Remove(item);
    }
    public bool Contains(Video item)
    {
      return List.Contains(item);
    }
    public int IndexOf(Video item)
    {
      return List.IndexOf(item);
    }
    public void CopyTo(Video[] array, int index)
    {
      List.CopyTo(array, index);
    }

    public Video this[int index]
    {
      get { return (Video)List[index]; }
      set { List[index] = value; }
    }

    public Video this[string label]
    {
      get {
        foreach (Video v in List)
        {
          if (v.Label == label)
            return v;
        }
        return null;
      }
    }
    
    public Video Set(string label)
    {
      foreach (Video v in List)
      {
        if (v.Label == label)
          return v;
      }

      Video item = new Video(label);
      Add(item);
      return item;
    }
  } 
}
